<template>
<el-container>
  <el-header style="text-align: right; font-size: 20px">
      <a @click="log">{{login}}</a>
      <el-dropdown @command="handleCommand">
              <a class="personal-link">
                <span class="username">{{ user }}</span>
              </a>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item command="logout">退出登录</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
  </el-header>
  <el-container>
    <el-aside style="width:200px">
        <el-menu style="height:750px;" default-active="1" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose">
            <router-link to="/home" tag="span">
            <el-menu-item index="1">
                <i class="el-icon-menu"></i>
                <span slot="title">首页</span>
            </el-menu-item>
            </router-link>
            <el-submenu index="2">
                <template slot="title">
                    <i class="el-icon-menu"></i>
                    <router-link to="/patientsetmeal" tag="span">预约</router-link>
                </template>
                <el-menu-item-group>
                    <router-link to="/notice" tag="span">
                    <el-menu-item index="2-1">预约须知</el-menu-item>
                    </router-link>
                    <router-link to="/report" tag="span">
                    <el-menu-item index="2-2">预约记录</el-menu-item>
                    </router-link>
                </el-menu-item-group>
            </el-submenu>
            <router-link to="/viewreport" tag="span">
            <el-menu-item index="3">
                <i class="el-icon-menu"></i>
                <span slot="title">报告查询</span>
            </el-menu-item>
            </router-link>
            <!-- <router-link to="/questionnaire" tag="span">
            <el-menu-item index="4">
                <i class="el-icon-menu"></i>
                <span slot="title">健康评估</span>
            </el-menu-item> -->
            </router-link>
            <router-link to="/intervene" tag="span">
            <el-menu-item index="5">
                <i class="el-icon-menu"></i>
                <span slot="title">干预方案</span>
            </el-menu-item>
            </router-link>
            <el-submenu index="6">
                <template slot="title">
                    <i class="el-icon-menu"></i>
                    <span slot="title">健康档案</span>
                </template>
                <el-menu-item-group>
                    <router-link to="/basic" tag="span">
                    <el-menu-item index="6-1">基本信息</el-menu-item>
                    </router-link>
                </el-menu-item-group>
            </el-submenu>
            <router-link to="/information" tag="span">
            <el-menu-item index="7">
                <i class="el-icon-menu"></i>
                <span slot="title">健康资讯</span>
            </el-menu-item>
            </router-link>
        </el-menu>
    </el-aside>
    <el-container>
      <router-view></router-view>
      <el-footer>Footer</el-footer>
    </el-container>
  </el-container>
</el-container>
</template>

<script>
export default {
    data() {
        return {
            user:"",
            login:"登录"
        }
    },
    methods: {
        log(){
            this.$router.push('/patientlogin')
        },
        handleOpen(key, keyPath) {
            console.log(key, keyPath);
        },
        handleClose(key, keyPath) {
            console.log(key, keyPath);
        },
        handleCommand(command) {
            switch(command) {
                case 'logout':
                sessionStorage.setItem("is_login", "");
                sessionStorage.setItem("is_loginID", "");
                sessionStorage.setItem("fn", "");
                this.$router.push('/home')
                break
            }
        },
        sa(){
            this.user = sessionStorage.getItem("is_login");
            console.log(this.user);
            if(this.user==""||this.user==null){
                this.login="登录"
            }else{
                this.login=""
            } 
        }
        
    },
    created: function(){
        this.sa()
    }
}
</script>

<style>

</style>